.TH std::chrono::duration::operator+(unary), 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::chrono::duration::operator+(unary), \- std::chrono::duration::operator+(unary),

.SH Synopsis

   constexpr duration operator+() const;                    \fI(until C++17)\fP
   constexpr std::common_type_t<duration>                   \fI(since C++17)\fP
   operator+() const;                               \fB(1)\fP
   constexpr duration operator-() const;                                  \fI(until C++17)\fP
   constexpr std::common_type_t<duration>               \fB(2)\fP               \fI(since C++17)\fP
   operator-() const;

   Implements unary plus and unary minus for the durations.

   If rep_ is a member variable holding the number of ticks in a duration object, and D
   is the return type,

   1) Equivalent to return D(*this);.
   2) Equivalent to return D(-rep_);.

.SH Parameters

   \fI(none)\fP

.SH Return value

   1) A copy of this duration object.
   2) A copy of this duration object, with the number of ticks negated.

.SH Example


// Run this code

 #include <chrono>
 #include <iostream>

 int main()
 {
     constexpr std::chrono::seconds s1(-052);
     constexpr std::chrono::seconds s2 = -s1;

     std::cout << "Negated " << s1 << " are " << s2 << '\\n';
 }

.SH Output:

 Negated -42s are 42s

.SH See also

   operator++
   operator++(int) increments or decrements the tick count
   operator--      \fI(public member function)\fP
   operator--(int)
   operator+
   operator-
   operator*       implements arithmetic operations with durations as arguments
   operator/       \fI(function template)\fP
   operator%
   \fI(C++11)\fP
